package com.fjnu.dao.impl;

import com.fjnu.dao.IRoleDao;
import com.fjnu.dao.common.BaseDaoImpl;
import com.fjnu.dao.common.DaoException;
import com.fjnu.entities.Role;

import java.util.List;

import org.springframework.stereotype.Repository;


@Repository("roleDao")
public class RoleDAO extends BaseDaoImpl<Role> implements IRoleDao{

	@Override
	public void addRole(Role role) {
		save(role);
		
	}

	@Override
	public void delRole(int id) {
		delete(id);
		
	}
	@Override
	public List<Role> findAllRole() {
		String hql="from Role";
		List<Role> list = findByHQL(hql);
		if(list.size()==0){
			throw new DaoException("角色信息为空");
		}
		return list;
	}

	@Override
	public Role findRoleUnique(int id) {
		
		return findById(id);
	}
}
